<?php
function db_get_time_ticket($current)
{
	$html = "";
	for($i=0;$i<=1;$i++)
	{
			if($i==0)
				$a='am';
			else if($i==1)
				$a = 'pm';	
		for($j=0;$j<=12;$j++)
		{			
			$key = $j.' '.$a;	
			if($current==$key)
			{	
				$html.= '<option selected="selected" value="'.$key.'">'.$key.'</option>';
			}
			else 
			{
				$html.= '<option value="'.$key.'">'.$key.'</option>';
			}
		}		
	}	
	echo $html;
}
?>
<div class="row-1">
						<h3><span>1</span>Book ticket</h3>
                        <div class="box-bottom">
                        	<p>
                            	<label>Transport :<span class="red">*</span></label>
                                <select name="transport_ticket" id="transport_ticket">
                                	<option value=""> Transport </option>
                                	<option <?php if($_SESSION['booking_hote_data']['transport_ticket']=="car") echo 'selected="selected"';?> value="car"> Car </option>
                                	<option <?php if($_SESSION['booking_hote_data']['transport_ticket']=="train") echo 'selected="selected"';?> value="train"> Train </option>
                                	<option <?php if($_SESSION['booking_hote_data']['transport_ticket']=="flight") echo 'selected="selected"';?> value="flight"> Flight </option>
                                </select>
                                <label id="contact_error_transport_ticket" class="contact_error">*</label>
                            </p>
                        	<p>                            	
                                <input type="radio" <?php if($_SESSION['booking_hote_data']['returnoneway']=="return") echo 'checked="checked"';?> name="returnoneway" value="return"/>
                                <span class="label">Return</span>
                                <input type="radio" name="returnoneway"  value="one way" <?php if($_SESSION['booking_hote_data']['returnoneway']=="one way") echo 'checked="checked"';?>/>
                                <span class="label">One way</span>
                            </p>                            
                            <p>
                            <?php
                            $where_go = db_get_where_to_you_go(); 
                            ?>
                            	<label>From :<span class="red">*</span></label>
                                <select name="from_ticket" id="from_ticket">
                                	<option value=""> Select</option>
                                	<?php
                                	foreach ($where_go as $value) 
                                	{
                                		if($_SESSION['booking_hote_data']['from_ticket'] == $value)
                                		{
                                		?>
                                		<option selected="selected" value="<?php echo $value;?>"> <?php echo $value;?></option>
                                		<?php 	
                                		}
                                		else 
                                		{
                                		?>
                                		<option value="<?php echo $value;?>"> <?php echo $value;?></option>
                                		<?php 	
                                		}
                                	} 
                                	?>
                                </select>
                                <label id="contact_error_from_ticket" class="contact_error">*</label>
                            </p>
                            <p>
                            	<label>To :<span class="red">*</span></label>
                                <select name="to_ticket" id="to_ticket">
                                	<option value=""> Select</option>
                                	<?php
                                	foreach ($where_go as $value) 
                                	{
                                		if($_SESSION['booking_hote_data']['to_ticket'] == $value)
                                		{
                                		?>
                                		<option selected="selected" value="<?php echo $value;?>"> <?php echo $value;?></option>
                                		<?php 	
                                		}
                                		else 
                                		{
                                		?>
                                		<option value="<?php echo $value;?>"> <?php echo $value;?></option>
                                		<?php 	
                                		}
                                	} 
                                	?>
                                </select>
                                <label id="contact_error_to_ticket" class="contact_error">*</label>
                            </p>
                            <p>
                            	<label>Check in date :<span class="red">*</span></label> 
                            	                            
                                <select class="hms" name="time_in_ticket">
                                	<?php
                                	$current = $_SESSION['booking_hote_data']['time_in_ticket'];
                                	db_get_time_ticket($current); 
                                	?>
                                </select>
                                
                                <?php
                            	 if(isset($_SESSION['booking_hote_data']) && $_SESSION['booking_hote_data']['check_in_dy_ticket']!=null)
                            	{
                            		$newDate_ID 	= $_SESSION['booking_hote_data']['check_in_dy_ticket'];
                            		$newDate_IM 	= $_SESSION['booking_hote_data']['check_in_mo_ticket'];
                            		$newDate_IY 	= $_SESSION['booking_hote_data']['check_in_yr_ticket'];            		
                            		
                            	}
                            	else 
                            	{
                            		 $originalDate = date('Y-m-d h:i:s');                                                
                                                $newDate_IY = date("Y", strtotime($originalDate));
                                                $newDate_IM = date("m", strtotime($originalDate));
                                                $newDate_ID = date("d", strtotime($originalDate));
                            	} 
                            	$date = date('Y');
                            	?>   
                                <select name="check_in_dy_ticket" id="check_in_dy_ticket">
                                	<?php
                    							for($i = 1;$i<=30;$i++)
                    							{
                    								if($i == $newDate_ID)
                    								{
                    								?>
                    									<option selected="selected" value="<?php echo $i;?>"><?php echo $i;?></option>
                    								<?php	
                    								}
                    								else 
                    								{
                    							?>
                    								<option value="<?php echo $i;?>"><?php echo $i;?></option>
                    							<?php
                    								} 								
                    							}	 
                    							?>
                                </select>
                                <select name="check_in_mo_ticket" id="check_in_mo_ticket">
                                	<option <?php if($newDate_IM == 1) echo 'selected="selected"';?> value="01">January </option>
                                                <option <?php if($newDate_IM == 2) echo 'selected="selected"';?> value="02">February </option>
                                                <option <?php if($newDate_IM == 3) echo 'selected="selected"';?> value="03">March </option>
                                                <option <?php if($newDate_IM == 4) echo 'selected="selected"';?> value="04">April </option>
                                                <option <?php if($newDate_IM == 5) echo 'selected="selected"';?> value="05">May </option>
                                                <option <?php if($newDate_IM == 6) echo 'selected="selected"';?> value="06">June </option>
                                                <option <?php if($newDate_IM == 7) echo 'selected="selected"';?> value="07">July </option>
                                                <option <?php if($newDate_IM == 8) echo 'selected="selected"';?> value="08">August </option>
                                                <option <?php if($newDate_IM == 9) echo 'selected="selected"';?> value="09">September </option>
                                                <option <?php if($newDate_IM == 10) echo 'selected="selected"';?> value="10">October </option>
                                                <option <?php if($newDate_IM == 11) echo 'selected="selected"';?> value="11">November </option>
                                                <option <?php if($newDate_IM == 12) echo 'selected="selected"';?> value="12">December </option>
                                </select>
                                <select name="check_in_yr_ticket" id="check_in_yr_ticket">
                                	<?php                    								
                    								for($y = $date; $y <= $date+5 ; $y++)
                    								{
                    									if($y == $newDate_IY)
                    									{
                    									?>
                    										<option selected="selected" value="<?php echo $y;?>"> <?php echo $y;?> </option>
                    									<?php 										
                    									}
                    									else 
                    									{
                    									?>
                    										<option value="<?php echo $y;?>"> <?php echo $y;?> </option>
                    									<?php 	
                    									}					
                    								}				
                    							?>
                                </select>
                                <label id="contact_error_check_in_ticket" class="contact_error">*</label>
                            </p>
                            <p>
                            	<label>Check out date :<span class="red">*</span></label>
                                <select class="hms" name="time_out_ticket">
                                	<?php
                                	$current = $_SESSION['booking_hote_data']['time_out_ticket'];
                                	db_get_time_ticket($current); 
                                	?>
                                </select>
                                <?php
                            	 if(isset($_SESSION['booking_hote_data']) && $_SESSION['booking_hote_data']['check_out_dy_ticket']!=null)
                            	{
                            		$newDate_ID 	= $_SESSION['booking_hote_data']['check_out_dy_ticket'];
                            		$newDate_IM 	= $_SESSION['booking_hote_data']['check_out_mo_ticket'];
                            		$newDate_IY 	= $_SESSION['booking_hote_data']['check_out_yr_ticket'];            		
                            		
                            	}
                            	else 
                            	{
                            		 $originalDate = date('Y-m-d h:i:s');                                                
                                                $newDate_IY = date("Y", strtotime($originalDate));
                                                $newDate_IM = date("m", strtotime($originalDate));
                                                $newDate_ID = date("d", strtotime($originalDate));
                            	} 
                            	$date = date('Y');
                            	?>
                                <select name="check_out_dy_ticket" id="check_out_dy_ticket">
                                	<?php
                    							for($i = 1;$i<=30;$i++)
                    							{
                    								if($i == $newDate_ID)
                    								{
                    								?>
                    									<option selected="selected" value="<?php echo $i;?>"><?php echo $i;?></option>
                    								<?php	
                    								}
                    								else 
                    								{
                    							?>
                    								<option value="<?php echo $i;?>"><?php echo $i;?></option>
                    							<?php
                    								} 								
                    							}	 
                    							?>
                                </select>
                                <select name="check_out_mo_ticket" id="check_out_mo_ticket">
                                	<option <?php if($newDate_IM == 1) echo 'selected="selected"';?> value="01">January </option>
                                                <option <?php if($newDate_IM == 2) echo 'selected="selected"';?> value="02">February </option>
                                                <option <?php if($newDate_IM == 3) echo 'selected="selected"';?> value="03">March </option>
                                                <option <?php if($newDate_IM == 4) echo 'selected="selected"';?> value="04">April </option>
                                                <option <?php if($newDate_IM == 5) echo 'selected="selected"';?> value="05">May </option>
                                                <option <?php if($newDate_IM == 6) echo 'selected="selected"';?> value="06">June </option>
                                                <option <?php if($newDate_IM == 7) echo 'selected="selected"';?> value="07">July </option>
                                                <option <?php if($newDate_IM == 8) echo 'selected="selected"';?> value="08">August </option>
                                                <option <?php if($newDate_IM == 9) echo 'selected="selected"';?> value="09">September </option>
                                                <option <?php if($newDate_IM == 10) echo 'selected="selected"';?> value="10">October </option>
                                                <option <?php if($newDate_IM == 11) echo 'selected="selected"';?> value="11">November </option>
                                                <option <?php if($newDate_IM == 12) echo 'selected="selected"';?> value="12">December </option>
                                </select>
                                <select name="check_out_yr_ticket" id="check_out_yr_ticket">
                                	<?php                    								
                    								for($y = $date; $y <= $date+5 ; $y++)
                    								{
                    									if($y == $newDate_IY)
                    									{
                    									?>
                    										<option selected="selected" value="<?php echo $y;?>"> <?php echo $y;?> </option>
                    									<?php 										
                    									}
                    									else 
                    									{
                    									?>
                    										<option value="<?php echo $y;?>"> <?php echo $y;?> </option>
                    									<?php 	
                    									}					
                    								}				
                    							?>
                                </select>
                                <label id="contact_error_check_out_ticket" class="contact_error">*</label>
                            </p>
                            <p>
                            	<label>Adults :<span class="red">*</span></label>
                                <input style="float: left;" name="adults_ticket" id="adults_ticket" type="text" value="<?php if($_SESSION['booking_hote_data']['adults_ticket']!=null) echo $_SESSION['booking_hote_data']['adults_ticket'];?>" /> 
                                <label id="contact_error_adults_ticket" class="contact_error">*</label>                               
                            </p>
                            <p>
                            	<label>Children ( 2-11 year ) :</label>
                                <input name="children_ticket" type="text"  value="<?php if($_SESSION['booking_hote_data']['children_ticket']!=null) echo $_SESSION['booking_hote_data']['children_ticket'];?>"/>                                
                            </p>
                            <p>
                            	<label>Infant ( under 2 year ) :</label>
                                <input type="text" name="infant_ticket" value="<?php if($_SESSION['booking_hote_data']['infant_ticket']!=null) echo $_SESSION['booking_hote_data']['infant_ticket'];?>" />                                
                            </p>
                            <p>                            	
                                <input name="radio_ticket" type="radio" value="I need to travel on this date" <?php if($_SESSION['booking_hote_data']['radio_ticket']=="on date") echo 'checked="checked"';?> />
                                <span class="label">I need to travel on this date</span>
                            </p>
                            <p>                            	
                                <input name="radio_ticket" type="radio" value="I just want the cheapest flight" <?php if($_SESSION['booking_hote_data']['radio_ticket']=="no on date") echo 'checked="checked"';?>/>
                                <span class="label">I just want the cheapest flight</span>                                
                            </p>                           
                    </div>                  	
                    </div>
       <script type="text/javascript" src="<?php bloginfo('template_url');?>/js/myticket-flight.js"></script>
	<style>
		.contact_error
		{
			display:none;
		}
		.contact_error_show
		{
			display:block;
			color:red;
			font-weight:bold;
			float:left;
			margin-left:5px;
		}
	</style>                